//
// Created by Wirano on 2020/11/9.
//

#ifndef ANO_FLIGHTCTRL_H
#define ANO_FLIGHTCTRL_H
/* Includes ------------------------------------------------------------------*/
#include "Ano_FcData.h"
#include "Ano_Filter.h"
#include "Ano_Math.h"

/* Exported types ------------------------------------------------------------*/

enum {
    null = 0,
    takeoff,
    landing,

    s_up_down_2, //小幅度上升下降2次

    s_yaw_pn_2,  //小幅度左右转2次
    b_yaw_pn_1,  //大幅度左右转1次

    s_rol_pn_2,  //小幅度左右2次
    b_rol_pn_1,  //大幅度左右1次

    s_pit_pn_2,  //小幅度前后2次
    b_pit_pn_1,  //大幅度前后1次

    yaw_n360,   //左转1圈
    yaw_p360,   //右转1圈

    roll_1,    //翻滚

    pit_jump_pn_2,  //前后跳2次
    rol_jump_pn_2,  //左右跳2次

    rol_up_down_2,  //蛇形上升下降
    yaw_up_dowm_1,  //旋转上升下降		2
    pit_rol_pn_2,   //蛇形前进后退		3

};
/**
 * 飞行状态参数结构体
 * 飞行过程中涉及到的飞行高度，飞行速度
 */
typedef struct {
    int16_t alt_ctrl_speed_set; // 高度控制速度
    float speed_set_h[VEC_XYZ];
    float speed_set_h_cms[VEC_XYZ]; //

    float speed_set_h_norm[VEC_XYZ];
    float speed_set_h_norm_lpf[VEC_XYZ];

} _flight_state_st;
extern _flight_state_st fs; //飞行状态参数结构体


typedef struct {
    uint8_t of_qua;
    uint16_t of_alt;
    uint16_t valid_of_alt_cm;

} _judge_sync_data_st;
extern _judge_sync_data_st jsdata;

/* Exported constants --------------------------------------------------------*/
extern float wifi_selfie_mode_yaw_vlue;

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void user_fun(float dT, uint8_t action_num);

void All_PID_Init(void);

void one_key_take_off(void);

void one_key_land(void);

void one_key_roll(void);

void app_one_key_roll(void);

void app_one_key_roll_reset(void);

void one_key_take_off_task(uint16_t dt_ms);

void ctrl_parameter_change_task(void);

void Flight_State_Task(uint8_t, int16_t *CH_N);

void Flight_Mode_Set(uint8_t dT_ms);

void Swtich_State_Task(uint8_t dT_ms);

#endif //ANO_FLIGHTCTRL_H
